package com.xucranger.ojapi.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xucranger.ojapi.enity.DTO.CodeforcesDTO;
import com.xucranger.ojapi.enity.DTO.CodeforcesQueryDTO;
import com.xucranger.ojapi.enity.DTO.RankDTO;
import com.xucranger.ojapi.enity.DTO.common.PageResultDTO;
import com.xucranger.ojapi.enity.DTO.common.ResponseDTO;
import com.xucranger.ojapi.enity.VO.CareeVO;
import com.xucranger.ojapi.enity.VO.CodeforcesVO;
import com.xucranger.ojapi.enity.VO.RankVO;
import com.xucranger.ojapi.service.CodeforcesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/codeforces")
public class CodeforcesController {

    @Autowired
    CodeforcesService codeforcesService;

    //根据id查询作题类数量

    //根据id查询参加比赛
    @PostMapping("/querycontestbyid")
    public ResponseDTO<PageResultDTO<CodeforcesVO>> QueryContestById(@RequestBody @Validated CodeforcesQueryDTO queryDTO){
        return codeforcesService.queryContestById(queryDTO);
    }

    //根据比赛查询学生
    @PostMapping("/querystudentbycontestname")
    public ResponseDTO<PageResultDTO<CodeforcesVO>> QueryStudentByContestname(@RequestBody @Validated CodeforcesQueryDTO queryDTO){
        return codeforcesService.queryStudentByContestname(queryDTO);
    }

    //根据cfid查询生涯
    @GetMapping("/querycareebycfid/{cfid}")
    public ResponseDTO<CareeVO> QueryCareeByCfid(@PathVariable("cfid") String cfid){
        return codeforcesService.queryCareeByCfid(cfid);
    }

    //根据比赛查询题目
    @GetMapping("/quiz/{cfcontestname}")
    public ResponseDTO<String> QueryQuizByTname(@PathVariable("cfcontestname") String cfcontestname){
        return null;
//        return codeforcesService.queryQuizByTname(cfcontestname);
    }
    //排行榜功能
    @PostMapping("/rank")
    public ResponseDTO<PageResultDTO<RankVO>> rank(@Validated @RequestBody RankDTO rankDTO){
        return codeforcesService.rank(rankDTO);
    }


}
